import { Graph, Node } from '@antv/x6';
import { ConditionTypeEnum, NODE_HEIGHT, NODE_TYPE_INTERMEDIATE_END, NODE_WIDTH, NodeTypeEnum } from '../constant';

// 导入所有节点注册函数
import { registerStartNode } from './start';
import { registerEndNode } from './end';
import { registerCommonNode } from './common';
import { registerThenNode } from './then';
import { registerWhenNode } from './when';
import { registerIfNode } from './if';
import { registerSwitchNode } from './switch';
import { registerForNode } from './for';
import { registerWhileNode } from './while';
import { registerAndNode } from './and';
import { registerOrNode } from './or';
import { registerNotNode } from './not';
import { registerCatchNode } from './catch';
import { registerIteratorNode } from './iterator';
import { registerVirtualNode } from './virtual';

/** 注册自定义节点到AntV X6 */
export function registerNodes() {
  // 注册基础节点
  registerStartNode();
  registerEndNode();
  registerCommonNode();
  
  // 注册编排节点
  registerThenNode();
  registerWhenNode();
  registerIfNode();
  registerSwitchNode();
  registerForNode();
  registerWhileNode();
  
  // 注册逻辑节点
  registerAndNode();
  registerOrNode();
  registerNotNode();
  
  // 注册特殊节点
  registerCatchNode();
  registerIteratorNode();
  registerVirtualNode();
}

export function getNodeShapeByType(nodeType) {
  switch(nodeType) {
    case NodeTypeEnum.BOOLEAN:
    case NodeTypeEnum.BOOLEAN_SCRIPT:
    case NodeTypeEnum.IF:
    case NodeTypeEnum.IF_SCRIPT:
      return NodeTypeEnum.IF;
    case NodeTypeEnum.SWITCH:
    case NodeTypeEnum.SWITCH_SCRIPT:
      return NodeTypeEnum.SWITCH;
    case NodeTypeEnum.FOR:
    case NodeTypeEnum.FOR_SCRIPT:
      return NodeTypeEnum.FOR;
    case NodeTypeEnum.WHILE:
    case NodeTypeEnum.WHILE_SCRIPT:
      return NodeTypeEnum.WHILE;
    case NodeTypeEnum.ITERATOR:
        return NodeTypeEnum.ITERATOR;
    case NodeTypeEnum.BREAK:
    case NodeTypeEnum.BREAK_SCRIPT:
      return NODE_TYPE_INTERMEDIATE_END;
    case NodeTypeEnum.VIRTUAL:
      return NodeTypeEnum.VIRTUAL;
    case NodeTypeEnum.COMMON:
    case NodeTypeEnum.FALLBACK:
    case NodeTypeEnum.SCRIPT:
    default:
      return NodeTypeEnum.COMMON;
  }
} 